package com.yql.controller;

import com.yql.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import com.yql.entity.*;

import javax.servlet.http.HttpSession;

@Controller
public class MenuController {
    @Autowired
    MenuService menuService;
    @GetMapping("tree")
    public String tree(){
        return "tree";
    }

    @ResponseBody
    @PostMapping("getTree")
    public List<Menu> getTree(HttpSession session){
        User user = (User) session.getAttribute("user");
        return menuService.getTree(user);
    }
}
